package com.spring.sunflower.userinfo

import com.spring.sunflower.base.BaseObserver
import com.spring.sunflower.base.BasePresenter
import com.spring.sunflower.bean.BlackHasBean
import com.spring.sunflower.bean.STSCertBean
import com.spring.sunflower.common.CommonContract
import io.reactivex.rxjava3.core.Observable

/**
 * Created by Kevin on 2021/8/16<br/>
 *
 * Describe:<br/>
 */
class AuthRealPresenter(baseView: CommonContract.AuthRealView) :
    BasePresenter<CommonContract.AuthRealView>(baseView) {
    fun getSTSCert() {
        val observable: Observable<STSCertBean> = requestDataSource.getSTSCert()
        addDisposable(observable, object : BaseObserver<STSCertBean?>(baseView) {
            override fun onSuccess(bean: STSCertBean?) {
                val datas = bean!!.datas
                baseView.loadSTSCert(datas)
            }

            override fun onError(status: Int, msg: String) {}

        })
    }

    fun requestRealAuth(authPhotoPath: String, photoPath: String) {
        val observable: Observable<BlackHasBean> =
            requestDataSource.realAuth(authPhotoPath, photoPath)
        addDisposable(observable, object : BaseObserver<BlackHasBean>(baseView) {
            override fun onSuccess(bean: BlackHasBean?) {
                baseView.authRealSuccess()
            }

            override fun onError(status: Int, msg: String) {
                baseView.authRealFailed()
            }

        })
    }
}